import { Component,ViewChild,OnInit,AfterViewInit,AfterViewChecked } from '@angular/core';
import { FormsModule } from "@angular/forms";
import { PriceQuote } from "./price-quote/price-quote.component";
import { CviewComponent } from "./cview/cview.component";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit,AfterViewInit,AfterViewChecked {

  @ViewChild("child1")
  child1: CviewComponent;

  title = 'Tom';
  stock="";
  greeting:string = "helloaaaaaa";
  user:{name:string} = {name: 'Tooom'};
  
  priceQuote: PriceQuote = new PriceQuote("", 0);

  priceQuoteHandler(event: PriceQuote) {
    this.priceQuote = event;
  }

  buyHandler(event: PriceQuote) {
    this.priceQuote = event;
  }

  ngOnInit() {
    // setInterval(()=>{
    //   this.child1.greeting("这是我在父组件中调用子组件的方法。");
    // },5000);

    this.child1.greeting("这是我在父组件中调用子组件的方法。");
  }

  ngAfterViewInit() {
    console.log("父组件的视图初始化完毕");
  }

  ngAfterViewChecked() {
    console.log("父组件的视图---跟新检测完毕");
  }

}
